package com.gs.core.aop.examples;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import com.gs.core.domain.User;

@Component
@Aspect
public class AfterReturningExample {
	//any void method
	@AfterReturning(" (execution(void *(..))) ")
	public void voidMethodChecks(JoinPoint jp){
        String msg = "DO @AfterReturning voidMethodChecks " + jp.getSignature().getName();
        System.out.println(msg);
	}
	@AfterReturning(" (execution(* com.gs..*Service.*(..))) ")
	public void doServiceMethods(JoinPoint jp){
        String msg = "DO @AfterReturning doServiceMethods Check " + jp.getSignature().getName();
        System.out.println(msg);
	}
	
	@AfterReturning(pointcut=" (execution(* com.gs..*Service.*(..))) ",returning="retValue")
	public void doServiceMethodsValue(User retValue){
        String msg = "DO @AfterReturning doServiceMethods Check returnValue : " + retValue;
        
        System.out.println(msg);
        if(retValue!=null)
        System.out.println(retValue.toString());
	}
	
}
